﻿namespace ModuleOne
{
    using MEF_Test.Bricks;
    using MEF_Test.Bricks.TemplateProvider;
    using MEF_Test.Contracts;

    using Microsoft.Practices.Unity;

    /// <summary>
    /// Interaction logic for ModuleOneBrowser.xaml
    /// </summary>
    public partial class ModuleOneBrowser
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ModuleOneBrowser"/> class.         
        /// </summary>
        public ModuleOneBrowser()
        {
            var browerNodeTemplateSelector = new BrowserNodeTemplateSelector();

            // Initialize Dependencies.
            var mediaHandlerFactory = IoC.Current.Resolve<IMediaHandlerFactoryProvider>();
            var templateProvider = IoC.Current.Resolve<TemplateProvider>();
            var browserDetailViewModelFactory = IoC.Current.Resolve<IBrowserDetailViewModelFactory>();

            IDiskFileHandlerFactory fileHandlerFactory = new LocalDiskFileHandlerFactory();
            
            IDiskBrowserNodeViewModelFactory localDiskBrowserNodeViewModelFactory = new LocalDiskBrowserNodeViewModelFactory(browserDetailViewModelFactory);

            DataContext = new ModuleOneBrowserViewModel(
                fileHandlerFactory, 
                mediaHandlerFactory, 
                templateProvider, 
                localDiskBrowserNodeViewModelFactory, 
                browerNodeTemplateSelector);
                                    
            InitializeComponent();
        }
    }
}
